package cn.org.book.shop.common.utils.bean;

/**
 * 文件对象存储Bean
 * Created with IntelliJ IDEA.
 * User:  wanghongjie
 * Date:  2020/11/21 - 21:29
 * <p>
 * Description:
 */
public class CloudFileBean {

    /**
     * accessKey
     */
    public String accessKey;
    /**
     * secretKey
     */
    public String secretKey;
    /**
     * 桶
     */
    public String bucket;
    /**
     * 文件名称
     */
    public String fileName;
    /**
     * 下载文件域名
     */
    public String domainOfBucket;
    /**
     * 文件hash
     */
    public String hash;


    public String getDownLoadUrl() {
        return domainOfBucket.concat("/").concat(fileName);
    }

    public CloudFileBean(String accessKey, String secretKey, String bucket, String fileName, String domainOfBucket) {
        this.accessKey = accessKey;
        this.secretKey = secretKey;
        this.bucket = bucket;
        this.fileName = fileName;
        this.domainOfBucket = domainOfBucket;
    }

    public CloudFileBean(String fileName, String domainOfBucket) {
        this.fileName = fileName;
        this.domainOfBucket = domainOfBucket;
    }

    /**
     * 构造七牛云存储对象
     *
     * @param accessKey      accessKey
     * @param secretKey      secretKey
     * @param bucket         桶
     * @param fileName       文件名称
     * @param domainOfBucket 下载域名
     * @return
     */
    public static CloudFileBean of(final String accessKey, final String secretKey, final String bucket, final String fileName, final String domainOfBucket) {
        return new CloudFileBean(accessKey, secretKey, bucket, fileName, domainOfBucket);
    }


}